package com.qjc.mq.listener;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;

/**
 * @ClassName: SendCallbackListener
 * @Description: RocketMQ异步回调
 * @Author: qjc
 * @Date: 2021/12/13 2:35 下午
 */
@Slf4j
public class SendCallbackListener implements SendCallback {
    @Override
    public void onSuccess(SendResult sendResult) {
        System.out.println("异步消息发送成功: " + JSONObject.toJSONString(sendResult));
    }

    @Override
    public void onException(Throwable throwable) {
        log.error("异步消息发送异常: ", throwable);
    }
}
